import Vue from 'vue'
import App from './App.vue'
import router from './router'
import less from 'less'
import axios from 'axios'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import ZkTable from 'vue-table-with-tree-grid'

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

 
//导入全局样式
import './assets/css/gload.css'
// 导入icon图标
import './assets/fonts/iconfont.css'
//配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//请求拦截器开启进度条NProgress.start();
axios.interceptors.request.use(config=>{
  NProgress.start();
  config.headers.Authorization=window.sessionStorage.getItem('token')
  return config
})
//响应拦截器关闭进度条NProgress.done();
axios.interceptors.response.use(data=>{
  NProgress.done();
  return data
})
Vue.prototype.$http = axios

Vue.use(ElementUI)
Vue.use(less)
Vue.component('tree-table', ZkTable)
// 全局时间过滤器
Vue.filter('dateFormat',function(origin){
  const dt=new Date(origin)
  const y=dt.getFullYear()
  const m=(dt.getMonth()+1+'').padStart(2,'0')
  const d=(dt.getDate() +'').padStart(2,'0')

  const hh=(dt.getHours() +'').padStart(2,'0')
  const mm=(dt.getMinutes()+'').padStart(2,'0')
  const ss =(dt.getSeconds()+'').padStart(2,'0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
